
import { Component, OnInit, Input } from '@angular/core';


export class CardComponentProperty {
    leftIconClassName?: string = "";
    rightIconClassName: string = "fa fa-angle-right";
    titleFontSize: string = "1em";
    subTitleFontSize: string = "0.5em";
    footer: string = "";

    constructor(public title: string,
                public subTitle: string,
                public titleColor: string = "black", 
                public subTitleColor: string= "gray") {

    }

}


@Component({
    selector: 'card-component',
    templateUrl: 'card.component.html',
})
export class CardComponent implements OnInit {

    @Input() properties: CardComponentProperty;



    ngOnInit() {
        // TODO 
    }


    getLeftIconClassNames() {
        return this._getNgClassObjectFromClassesString(this.properties.leftIconClassName);
    }

    getRightIconClassNames() {
        return this._getNgClassObjectFromClassesString(this.properties.rightIconClassName);
    }

    private _getNgClassObjectFromClassesString(classes: string) {
        if (classes !== '') {
            return classes.split(" ")
                .map((cls) => cls.trim())
                .reduce((prev, current) => {
                    prev[current] = true;
                    return prev;
                }, {});
        }
        return {};
    }

    get footer(): string {
        return this.properties.footer;
    }


}
